package com.devilvan.betrice.poetry.controller;

import com.devilvan.betrice.annotation.BetriceRunTime;
import com.devilvan.betrice.common.BetriceResultVo;
import com.devilvan.betrice.poetry.po.PoetryHeaderPo;
import com.devilvan.betrice.poetry.service.PoetryHeaderService;
import com.xxl.job.core.handler.annotation.XxlJob;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Evad.Wu
 * @Description 古诗文网-头信息表 控制器
 * @date 2022-11-29
 */
@RestController
@RequestMapping(value = "poetryHeaderController")
@Tag(name = "古诗文网-头信息表 控制器")
public class PoetryHeaderController {
    @Resource(name = "poetryHeaderServiceImpl")
    private PoetryHeaderService poetryHeaderService;

    /**
     * 采集报文定时器
     *
     * @param keyword 作品关键字
     * @return 形式返回
     */
    @Operation(summary = "采集报文定时器")
    @XxlJob(value = "doPoetryHeaderExecutor")
    @GetMapping(value = "doPoetryHeaderExecutor")
    public BetriceResultVo<PoetryHeaderPo> doPoetryExecutor() {
        return poetryHeaderService.doPoetryHeaderCrawler(null);
    }

    /**
     * 采集报文控制器
     *
     * @param keyword 作品关键字
     * @return 形式返回
     */
    @BetriceRunTime
    @Operation(summary = "采集报文控制器")
    @GetMapping(value = "doPoetryHeaderCrawler")
    public BetriceResultVo<PoetryHeaderPo> doPoetryHeaderCrawler(@RequestParam(required = false) String keyword) {
        return poetryHeaderService.doPoetryHeaderCrawler(keyword);
    }

    /**
     * 采集报文控制器，诗经、乐府、楚辞页面特殊处理
     *
     * @return 形式返回
     */
    @Operation(summary = "采集报文控制器，诗经、乐府、楚辞页面特殊处理")
    @GetMapping(value = "doPoetryHeaderSpecificCrawler")
    public BetriceResultVo<PoetryHeaderPo> doPoetryHeaderSpecificCrawler() {
        return poetryHeaderService.doPoetryHeaderSpecificCrawler();
    }

}
